/*
 *  AudioRecorderTester.cpp
 *  SoundController0002
 *
 *  Created by jiro on 10/07/05.
 *  Copyright 2010 jiro music. All rights reserved.
 *
 */

#include "AudioRecorderTester.h"
#include "../AudioRecorder.h"
#include "../Constants.h"
#include "CustomAssert.h"

namespace sc 
{
	const float error = 0.000001;
	 
	void AudioRecorderTester::TestAll()
	{
		Test_Record_001();
		
		Test_Record_002();
		
		Test_Record_003();
		
		Test_Record_004();
		
		Test_Record_005();
		
		Test_Record_006();
		
		Test_Record_007();
		
		Test_Record_008();
		
		Test_Record_009();
		
		Test_Record_010();
		
		Test_Record_011();
		
		Test_Record_012();
		
		Test_Record_013();
		
		Test_Record_014();
		
		Test_Record_015();
		
		Test_Record_016();
		
		Test_Record_017();
		
		Test_Record_018();
		
		Test_Record_019();
		
		Test_Record_020();
		
		Test_Record_021();
		
		Test_Record_022();
		
		Test_Record_023();
		
		Test_Record_024();
		
		Test_Record_025();
		
		Test_Record_026();
		
		Test_Record_027();
		
		Test_Record_028();
		
		Test_Record_029();
	}

	void AudioRecorderTester::Test_Record_001()
	{
		{
			const SoundElement32* element = SoundElementFactory32::Create(
				true,
				0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,  0.25, 1 ),
				0.25, & LineFactory::Create( Line::Type_Straight, 0.25, 1,  0.50, 1 ),
				0.25, & LineFactory::Create( Line::Type_Straight, 0.50, 1,  0.75, 1 ),
				0.25, & LineFactory::Create( Line::Type_Straight, 0.75, 1,  1.0,  1 ),
				WaveTableFactory::Create( WaveTable::Type_Constant, 1.0 ) );

			AudioRecorder32 recorder( 1, 1 );
			recorder.Record( 0, 0, 0, element );
			
			std::vector< AudioData32 > audioData;
			recorder.GetAudioData( 0, audioData );

			AssertEqual( audioData.size(), Sampling_Rate_As_Double );
			for ( int i = 0; i < audioData.size(); i++ )
			{
				AssertEqual( audioData[ i ], 1.0 );
				if ( audioData[ i ] != 1.0 )
				{
					break;
				} 
			}

		}
		{
			const SoundElement32* element = SoundElementFactory32::Create(
				0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,  0.25, 1 ),
				0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,  0.50, 1 ),
				0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,  0.75, 1 ),
				1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,  1.0,  1 ),
				WaveTableFactory::Create( WaveTable::Type_Constant, 1.0 ) );

			AudioRecorder32 recorder( 1, 1 );
			recorder.Record( 0, 0, 0, element );
			
			std::vector< AudioData32 > audioData;
			recorder.GetAudioData( 0, audioData );

			AssertEqual( audioData.size(), Sampling_Rate_As_Double );
			for ( int i = 0; i < audioData.size(); i++ )
			{
				AssertEqual( audioData[ i ], 1.0 );
			}
		}
	}
		
	void AudioRecorderTester::Test_Record_002()
	{
		const SoundElement32* element = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    0.5,  0.25, 0.5 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,    0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,    0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,    1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1.0 ) );

		AudioRecorder32 recorder( 1, 1 );
		recorder.Record( 0, 0, 0, element );
		
		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );

		AssertEqual( audioData.size(), Sampling_Rate_As_Double );
		for ( int i = 0; i < Sampling_Rate_As_Double / 4 + 1; i++ )
		{
			AssertEqual( audioData[ i ], 0.5 );
		}
		for ( int i = Sampling_Rate_As_Double / 4 + 1; i < audioData.size(); i++ )
		{
			AssertEqual( audioData[ i ], 1.0 );
		}
	}
	
	void AudioRecorderTester::Test_Record_003()
	{
		const SoundElement32* element = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,  0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 0.5,    0.50, 0.5 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,    0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,    1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1.0 ) );

		AudioRecorder32 recorder( 1, 1 );
		recorder.Record( 0, 0, 0, element );
		
		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );

		AssertEqual( audioData.size(), Sampling_Rate_As_Double );
		for ( int i = 0; i < Sampling_Rate_As_Double / 4 + 1; i++ )
		{
			AssertEqual( audioData[ i ], 1 );
		}
		for ( int i = Sampling_Rate_As_Double / 4 + 1; i < Sampling_Rate_As_Double / 2; i++ )
		{
			AssertEqual( audioData[ i ], 0.5 );
		}
		for ( int i = Sampling_Rate_As_Double / 2; i < audioData.size(); i++ )
		{
			AssertEqual( audioData[ i ], 1.0 );
		}
	}
	
	void AudioRecorderTester::Test_Record_004()
	{
		const SoundElement32* element = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,  0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,    0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 0.5,    0.75, 0.5 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,    1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1.0 ) );

		AudioRecorder32 recorder( 1, 1 );
		recorder.Record( 0, 0, 0, element );
		
		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );

		AssertEqual( audioData.size(), Sampling_Rate_As_Double );
		for ( int i = 0; i < Sampling_Rate_As_Double / 2; i++ )
		{
			AssertEqual( audioData[ i ], 1 );
		}
		for ( int i = Sampling_Rate_As_Double / 2; i < 3 * Sampling_Rate_As_Double / 4; i++ )
		{
			AssertEqual( audioData[ i ], 0.5 );
		}
		for ( int i = 3 * Sampling_Rate_As_Double / 4; i < audioData.size(); i++ )
		{
			AssertEqual( audioData[ i ], 1.0 );
		}
	}

	void AudioRecorderTester::Test_Record_005()
	{
		const SoundElement32* element = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,  0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,    0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,    0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 0.5,    1.0,  0.5 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1.0 ) );

		AudioRecorder32 recorder( 1, 1 );
		recorder.Record( 0, 0, 0, element );

		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );

		AssertEqual( audioData.size(), Sampling_Rate_As_Double );
		for ( int i = 0; i < 3 * Sampling_Rate_As_Double / 4; i++ )
		{
			AssertEqual( audioData[ i ], 1 );
		}
		for ( int i = 3 * Sampling_Rate_As_Double / 4; i < audioData.size(); i++ )
		{
			AssertEqual( audioData[ i ], 0.5 );
		}
	}

	void AudioRecorderTester::Test_Record_006()
	{
		const SoundElement32* element = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    0,  0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,    0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,    0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1	,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1.0 ) );

		AudioRecorder32 recorder( 1, 1 );
		recorder.Record( 0, 0, 0, element );

		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );

		AssertEqual( audioData.size(), Sampling_Rate_As_Double );
		float delta = 1.0 / ( Sampling_Rate_As_Double / 4 );
		for ( int i = 0; i < Sampling_Rate_As_Double / 4; i++ )
		{
			AssertEqualWithError( audioData[ i ], i * delta, error );
		}
		for ( int i = 3 * Sampling_Rate_As_Double / 4; i < audioData.size(); i++ )
		{
			AssertEqual( audioData[ i ], 1 );
		}
	}

	void AudioRecorderTester::Test_Record_007()
	{
		const SoundElement32* element = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 2 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1.0 ) );

		AudioRecorder32 recorder( 1, 1 );
		recorder.Record( 0, 0, 0, element );

		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );

		AssertEqual( audioData.size(), Sampling_Rate_As_Double );
		float delta = 1.0 / ( Sampling_Rate_As_Double / 4 );
		for ( int i = 0; i < Sampling_Rate_As_Double / 4; i++ )
		{
			AssertEqual( audioData[ i ], 1 );
		}
		for ( int i = Sampling_Rate_As_Double / 4; i < Sampling_Rate_As_Double / 2; i++ )
		{
			AssertEqualWithError( audioData[ i ], 1.0 + ( i - Sampling_Rate_As_Double / 4 ) * delta, error );
		}
		for ( int i = 3 * Sampling_Rate_As_Double / 4; i < audioData.size(); i++ )
		{
			AssertEqual( audioData[ i ], 1 );
		}
	}
	
	void AudioRecorderTester::Test_Record_008()
	{
		const SoundElement32* element = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 2 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1.0 ) );

		AudioRecorder32 recorder( 1, 1 );
		recorder.Record( 0, 0, 0, element );

		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );

		AssertEqual( audioData.size(), Sampling_Rate_As_Double );
		float delta = 1.0 / ( Sampling_Rate_As_Double / 4 );
		for ( int i = 0; i < Sampling_Rate_As_Double / 2; i++ )
		{
			AssertEqual( audioData[ i ], 1 );
		}
		for ( int i = Sampling_Rate_As_Double / 2; i < 3 * Sampling_Rate_As_Double / 4; i++ )
		{
			AssertEqualWithError( audioData[ i ], 1.0 + ( i - Sampling_Rate_As_Double / 2 ) * delta, error );
		}
		for ( int i = 3 * Sampling_Rate_As_Double / 4; i < audioData.size(); i++ )
		{
			AssertEqual( audioData[ i ], 1 );
		}
	}
	
	void AudioRecorderTester::Test_Record_009()
	{
		const SoundElement32* element = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  2 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1.0 ) );

		AudioRecorder32 recorder( 1, 1 );
		recorder.Record( 0, 0, 0, element );

		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );

		AssertEqual( audioData.size(), Sampling_Rate_As_Double );
		float delta = 1.0 / ( Sampling_Rate_As_Double / 4 );
		for ( int i = 0; i < 3 * Sampling_Rate_As_Double / 4; i++ )
		{
			AssertEqual( audioData[ i ], 1 );
		}
		for ( int i = 3 * Sampling_Rate_As_Double / 4; i < Sampling_Rate_As_Double; i++ )
		{
			AssertEqualWithError( audioData[ i ], 1.0 + ( i - 3 * Sampling_Rate_As_Double / 4 ) * delta, error );
		}
	}
	
	void AudioRecorderTester::Test_Record_010()
	{
		const SoundElement32* element = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1.0 ) );

		AudioRecorder32 recorder( 1, 1 );
		recorder.Record( 0, 0, 1, element );

		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );

		AssertEqual( audioData.size(), 2 * Sampling_Rate_As_Double );
		for ( int i = 0; i < Sampling_Rate_As_Double; i++ )
		{
			AssertEqual( audioData[ i ], 0.0 );
		}
		for ( int i = Sampling_Rate_As_Double; i < 2 * Sampling_Rate_As_Double; i++ )
		{
			AssertEqual( audioData[ i ], 1.0 );
		}
	}
	
	void AudioRecorderTester::Test_Record_011()
	{
		const SoundElement32* element = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Sine, 440.0 ) );

		AudioRecorder32 recorder( 1, 1 );
		recorder.Record( 0, 0, 0, element );

		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );

		AssertEqual( audioData.size(), Sampling_Rate_As_Double );
		for ( int i = 0; i < Sampling_Rate_As_Double; i++ )
		{
			AssertEqualWithError( audioData[ i ], sin( ( 2 * Pi * static_cast<double>( i ) / Sampling_Rate_As_Double ) * 440 ), error );
		}
	}
	
	void AudioRecorderTester::Test_Record_012()
	{
		const SoundElement32* element = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1.0 ) );

		AudioRecorder32 recorder( 1, 1 );
		recorder.Record( 0, 0, 0, element );
		recorder.Record( 0, 0, 2, element );

		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );

		AssertEqual( audioData.size(), 3 * Sampling_Rate_As_Double + 1 );
		for ( int i = 0; i < Sampling_Rate_As_Double; i++ )
		{
			AssertEqual( audioData[ i ], 1.0 );
		}
		for ( int i = Sampling_Rate_As_Double; i < 2 * Sampling_Rate_As_Double; i++ )
		{
			AssertEqual( audioData[ i ], 0.0 );
		}
		for ( int i = 2 * Sampling_Rate_As_Double; i < 3 * Sampling_Rate_As_Double + 1; i++ )
		{
			AssertEqual( audioData[ i ], 1.0 );
		}
	}

	void AudioRecorderTester::Test_Record_013()
	{
		const SoundElement32* element = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1.0 ) );
		const SoundElement32* element2 = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1.0 ) );

		AudioRecorder32 recorder( 1, 1 );
		recorder.Record( 0, 0, 0, element );
		recorder.Record( 0, 0, 0, element2 );

		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );

		AssertEqual( audioData.size(), Sampling_Rate_As_Double );
		for ( int i = 0; i < Sampling_Rate_As_Double; i++ )
		{
			AssertEqual( audioData[ i ], 2 );
		}
	}
	
	void AudioRecorderTester::Test_Record_014()
	{
		const SoundElement32* element = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1 ) );
		const SoundElement32* element2 = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1 ) );

		AudioRecorder32 recorder( 1, 1 );
		recorder.Record( 0, 0, 0, element );
		recorder.Record( 0, 0, 0.5, element2 );

		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );

		AssertEqual( audioData.size(), Sampling_Rate_As_Double * 3 / 2.0 );
		for ( int i = 0; i < Sampling_Rate_As_Double / 2; i++ )
		{
			AssertEqual( audioData[ i ], 1 );
		}
		for ( int i = Sampling_Rate_As_Double / 2; i < Sampling_Rate_As_Double; i++ )
		{
			AssertEqual( audioData[ i ], 2 );
		}
		for ( int i = Sampling_Rate_As_Double; i < 3 * Sampling_Rate_As_Double / 2; i++ )
		{
			AssertEqual( audioData[ i ], 1 );
		}
	}

	void AudioRecorderTester::Test_Record_015()
	{
		const SoundElement32* element = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Sine, 440.0 ) );
		const SoundElement32* element2 = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Sine, 880.0 ) );

		AudioRecorder32 recorder( 1, 1 );
		recorder.Record( 0, 0, 0, element );
		recorder.Record( 0, 0, 0, element2 );

		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );

		AssertEqual( audioData.size(), Sampling_Rate_As_Double );
		for ( int i = 0; i < Sampling_Rate_As_Double; i++ )
		{
			double x = ( 2.0 * Pi * static_cast<double>( i ) / Sampling_Rate_As_Double ) * 440;
			double x2 = ( 2.0 * Pi * static_cast<double>( i ) / Sampling_Rate_As_Double ) * 880;
			AssertEqualWithError( audioData[ i ], sin( x ) + sin( x2 ), error );
		}
	}
	
	void AudioRecorderTester::Test_Record_016()
	{
		const SoundElement32* element = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Sine, 440.0 ) );
		const SoundElement32* element2 = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Sine, 880.0 ) );

		AudioRecorder32 recorder( 1, 1 );
		recorder.Record( 0, 0, 0, element );
		recorder.Record( 0, 0, 0.5, element2 );

		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );

		AssertEqual( audioData.size(), Sampling_Rate_As_Double * 3 / 2.0 );
		for ( int i = 0; i < Sampling_Rate_As_Double / 2; i++ )
		{
			double x = ( 2.0 * Pi * static_cast<double>( i ) / Sampling_Rate_As_Double ) * 440;
			AssertEqualWithError( audioData[ i ], sin( x ), error );
		}
		for ( int i = Sampling_Rate_As_Double / 2; i < Sampling_Rate_As_Double; i++ )
		{
			double x = ( 2.0 * Pi * static_cast<double>( i ) / Sampling_Rate_As_Double ) * 440;
			double x2 = ( 2.0 * Pi * static_cast<double>( i - Sampling_Rate_As_Double / 2 ) / Sampling_Rate_As_Double ) * 880;
			AssertEqualWithError( audioData[ i ], sin( x ) + sin( x2 ), error );
		}
		for ( int i = Sampling_Rate_As_Double; i < 3 * Sampling_Rate_As_Double / 2; i++ )
		{
			double x2 = ( 2.0 * Pi * static_cast<double>( i - Sampling_Rate_As_Double / 2 ) / Sampling_Rate_As_Double ) * 880;
			AssertEqualWithError( audioData[ i ], sin( x2 ), error );
		}
	}

	void AudioRecorderTester::Test_Record_017()
	{
		const SoundElement32* element = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1.0 ) );

		AudioRecorder32 recorder( 1, 2 );
		recorder.Record( 0, 0, 0, element );
		recorder.Record( 0, 1, 2, element );

		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );

		AssertEqual( audioData.size(), Sampling_Rate_As_Double * 3 + 1);
		for ( int i = 0; i < Sampling_Rate_As_Double; i++ )
		{
			AssertEqual( audioData[ i ], 1.0 );
		}
		for ( int i = Sampling_Rate_As_Double; i < 2 * Sampling_Rate_As_Double; i++ )
		{
			AssertEqual( audioData[ i ], 0.0 );
		}
		for ( int i = 2 * Sampling_Rate_As_Double; i < 3 * Sampling_Rate_As_Double + 1; i++ )
		{
			AssertEqual( audioData[ i ], 1.0 );
		}
	}

	void AudioRecorderTester::Test_Record_018()
	{
		const SoundElement32* element = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1.0 ) );
		const SoundElement32* element2 = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1.0 ) );

		AudioRecorder32 recorder( 1, 2 );
		recorder.Record( 0, 0, 0, element );
		recorder.Record( 0, 1, 0, element2 );

		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );

		AssertEqual( audioData.size(), Sampling_Rate_As_Double );
		for ( int i = 0; i < Sampling_Rate_As_Double; i++ )
		{
			AssertEqual( audioData[ i ], 2 );
		}
	}
	
	void AudioRecorderTester::Test_Record_019()
	{
		const SoundElement32* element = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1 ) );
		const SoundElement32* element2 = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1 ) );

		AudioRecorder32 recorder( 1, 2 );
		recorder.Record( 0, 0, 0, element );
		recorder.Record( 0, 1, 0.5, element2 );

		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );

		AssertEqual( audioData.size(), Sampling_Rate_As_Double * 3 / 2.0 );
		for ( int i = 0; i < Sampling_Rate_As_Double / 2; i++ )
		{
			AssertEqual( audioData[ i ], 1 );
		}
		for ( int i = Sampling_Rate_As_Double / 2; i < Sampling_Rate_As_Double; i++ )
		{
			AssertEqualWithError( audioData[ i ], 2, error );
		}
		for ( int i = Sampling_Rate_As_Double; i < 3 * Sampling_Rate_As_Double / 2; i++ )
		{
			AssertEqual( audioData[ i ], 1 );
		}
	}
	
	void AudioRecorderTester::Test_Record_020()
	{
		const SoundElement32* element = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Sine, 440.0 ) );
		const SoundElement32* element2 = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Sine, 880.0 ) );

		AudioRecorder32 recorder( 1, 2 );
		recorder.Record( 0, 0, 0, element );
		recorder.Record( 0, 1, 0, element2 );

		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );

		AssertEqual( audioData.size(), Sampling_Rate_As_Double );
		for ( int i = 0; i < Sampling_Rate_As_Double; i++ )
		{
			double x = ( 2.0 * Pi * static_cast<double>( i ) / Sampling_Rate_As_Double ) * 440;
			double x2 = ( 2.0 * Pi * static_cast<double>( i ) / Sampling_Rate_As_Double ) * 880;
			AssertEqualWithError( audioData[ i ], sin( x ) + sin( x2 ), error );
		}
	}
	
	void AudioRecorderTester::Test_Record_021()
	{
		const SoundElement32* element = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Sine, 440.0 ) );
		const SoundElement32* element2 = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Sine, 880.0 ) );

		AudioRecorder32 recorder( 1, 2 );
		recorder.Record( 0, 0, 0, element );
		recorder.Record( 0, 1, 0.5, element2 );

		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );

		AssertEqual( audioData.size(), Sampling_Rate_As_Double / 2 * 3 );
		for ( int i = 0; i < Sampling_Rate_As_Double / 2; i++ )
		{
			double x = ( 2.0 * Pi * static_cast<double>( i ) / Sampling_Rate_As_Double ) * 440;
			AssertEqualWithError( audioData[ i ], sin( x ), error );
		}
		for ( int i = Sampling_Rate_As_Double / 2; i < Sampling_Rate_As_Double; i++ )
		{
			double x = ( 2.0 * Pi * static_cast<double>( i ) / Sampling_Rate_As_Double ) * 440;
			double x2 = ( 2.0 * Pi * static_cast<double>( i - Sampling_Rate_As_Double / 2 ) / Sampling_Rate_As_Double ) * 880;
			AssertEqualWithError( audioData[ i ], sin( x ) + sin( x2 ), error );
		}
		for ( int i = Sampling_Rate_As_Double; i < 3 * Sampling_Rate_As_Double / 2; i++ )
		{
			double x2 = ( 2.0 * Pi * static_cast<double>( i - Sampling_Rate_As_Double / 2 ) / Sampling_Rate_As_Double ) * 880;
			AssertEqualWithError( audioData[ i ], sin( x2 ), error );
		}
	}
	
	void AudioRecorderTester::Test_Record_022()
	{
		const SoundElement32* element = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1.0 ) );

		AudioRecorder32 recorder( 2, 1 );
		recorder.Record( 0, 0, 0, element );
		recorder.Record( 1, 0, 2, element );

		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );

		AssertEqual( audioData.size(), Sampling_Rate_As_Double );
		for ( int i = 0; i < Sampling_Rate_As_Double; i++ )
		{
			AssertEqual( audioData[ i ], 1.0 );
		}
		
		audioData.clear();
		recorder.GetAudioData( 1, audioData );
		for ( int i = 0; i < Sampling_Rate_As_Double * 2; i++ )
		{
			AssertEqual( audioData[ i ], 0.0 );
		}
		for ( int i = 2 * Sampling_Rate_As_Double; i < 3 * Sampling_Rate_As_Double; i++ )
		{
			AssertEqual( audioData[ i ], 1.0 );
		}
	}
	
	void AudioRecorderTester::Test_Record_023()
	{
		const SoundElement32* element = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1.0 ) );
		const SoundElement32* element2 = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1.0 ) );

		AudioRecorder32 recorder( 2, 1 );
		recorder.Record( 0, 0, 0, element );
		recorder.Record( 1,	0, 0, element2 );

		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );

		AssertEqual( audioData.size(), Sampling_Rate_As_Double );
		for ( int i = 0; i < Sampling_Rate_As_Double; i++ )
		{
			AssertEqual( audioData[ i ], 1 );
		}
		
		audioData.clear();
		recorder.GetAudioData( 1, audioData );
		for ( int i = 0; i < Sampling_Rate_As_Double; i++ )
		{
			AssertEqual( audioData[ i ], 1 );
		}

	}

	void AudioRecorderTester::Test_Record_024()
	{
		const SoundElement32* element = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1 ) );
		const SoundElement32* element2 = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1 ) );

		AudioRecorder32 recorder( 2, 1 );
		recorder.Record( 0, 0, 0, element );
		recorder.Record( 1, 0, 0.5, element2 );

		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );

		AssertEqual( audioData.size(), Sampling_Rate_As_Double );
		for ( int i = 0; i < Sampling_Rate_As_Double; i++ )
		{
			AssertEqual( audioData[ i ], 1 );
		}
		
		audioData.clear();
		recorder.GetAudioData( 1, audioData );
		AssertEqual( audioData.size(), 3 * Sampling_Rate_As_Double / 2 );
		for ( int i = 0; i < Sampling_Rate_As_Double / 2; i++ )
		{
			AssertEqual( audioData[ i ], 0 );
		}
		for ( int i = Sampling_Rate_As_Double / 2; i < 3 * Sampling_Rate_As_Double / 2; i++ )
		{
			AssertEqual( audioData[ i ], 1 );
		}
	}
	
	void AudioRecorderTester::Test_Record_025()
	{
		const SoundElement32* element = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Sine, 440.0 ) );
		const SoundElement32* element2 = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Sine, 880.0 ) );

		AudioRecorder32 recorder( 2, 1 );
		recorder.Record( 0, 0, 0, element );
		recorder.Record( 1, 0, 0, element2 );

		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );

		AssertEqual( audioData.size(), Sampling_Rate_As_Double );
		for ( int i = 0; i < Sampling_Rate_As_Double; i++ )
		{
			double x = ( 2.0 * Pi * static_cast<double>( i ) / Sampling_Rate_As_Double ) * 440;
			AssertEqualWithError( audioData[ i ], sin( x ), error );
		}
		
		audioData.clear();
		recorder.GetAudioData( 1, audioData );
		AssertEqual( audioData.size(), Sampling_Rate_As_Double );
		for ( int i = 0; i < Sampling_Rate_As_Double; i++ )
		{
			double x2 = ( 2.0 * Pi * static_cast<double>( i ) / Sampling_Rate_As_Double ) * 880;
			AssertEqualWithError( audioData[ i ], sin( x2 ), error );
		}

	}
	
	void AudioRecorderTester::Test_Record_026()
	{
		const SoundElement32* element = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Sine, 440.0 ) );
		const SoundElement32* element2 = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Sine, 880.0 ) );

		AudioRecorder32 recorder( 2, 1 );
		recorder.Record( 0, 0, 0, element );
		recorder.Record( 1, 0, 0.5, element2 );

		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );

		AssertEqual( audioData.size(), Sampling_Rate_As_Double );
		for ( int i = 0; i < Sampling_Rate_As_Double; i++ )
		{
			double x = ( 2.0 * Pi * static_cast<double>( i ) / Sampling_Rate_As_Double ) * 440;
			AssertEqualWithError( audioData[ i ], sin( x ), error );
		}
		
		audioData.clear();
		recorder.GetAudioData( 1, audioData );
		for ( int i = Sampling_Rate_As_Double / 2; i < 3 * Sampling_Rate_As_Double / 2; i++ )
		{
			double x2 = ( 2.0 * Pi * static_cast<double>( i - Sampling_Rate_As_Double / 2 ) / Sampling_Rate_As_Double ) * 880;
			AssertEqualWithError( audioData[ i ], sin( x2 ), error );
		}
	}
	
	void AudioRecorderTester::Test_Record_027()
	{
		const SoundElement32* element1 = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1) );
		const SoundElement32* element2 = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1) );
		const SoundElement32* element3 = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1) );
		const SoundElement32* element4 = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1) );

		AudioRecorder32 recorder( 1, 1 );
		recorder.Record( 0, 0, 0, element1 );
		recorder.Record( 0, 0, 0.25, element2 );
		recorder.Record( 0, 0, 0.50, element3 );
		recorder.Record( 0, 0, 0.75, element4 );

		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );
		
		AssertEqual( audioData.size(), Sampling_Rate_As_Double + 3 * Sampling_Rate_As_Double / 4 );
		int i = 0;
		for ( ; i < Sampling_Rate_As_Double / 4 + 1; i++ )
		{
			AssertEqual( audioData[ i ], 1 );
		}
		for ( ; i < 2 * Sampling_Rate_As_Double / 4; i++ )
		{
			AssertEqual( audioData[ i ], 2 );
		}
		for ( ; i < 3 * Sampling_Rate_As_Double / 4; i++ )
		{
			AssertEqual( audioData[ i ], 3 );
		}
		for ( ; i < Sampling_Rate_As_Double; i++ )
		{
			AssertEqual( audioData[ i ], 4 );
		}
		for ( ; i < Sampling_Rate_As_Double + Sampling_Rate_As_Double / 4; i++ )
		{
			AssertEqual( audioData[ i ], 3 );
		}
		for ( ; i < Sampling_Rate_As_Double + 2 * Sampling_Rate_As_Double / 4; i++ )
		{
			AssertEqual( audioData[ i ], 2 );
		}
		for ( ; i < Sampling_Rate_As_Double + 3 * Sampling_Rate_As_Double / 4; i++ )
		{
			AssertEqual( audioData[ i ], 1 );
		}
	}

	void AudioRecorderTester::Test_Record_028()
	{
		const SoundElement32* element1 = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1) );
		const SoundElement32* element2 = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1) );
		const SoundElement32* element3 = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1) );
		const SoundElement32* element4 = SoundElementFactory32::Create(
			0.25, & LineFactory::Create( Line::Type_Straight, 0,    1,	0.25, 1 ),
			0.50, & LineFactory::Create( Line::Type_Straight, 0.25, 1,	0.50, 1 ),
			0.75, & LineFactory::Create( Line::Type_Straight, 0.50, 1,	0.75, 1 ),
			1.0,  & LineFactory::Create( Line::Type_Straight, 0.75, 1,	1.0,  1 ),
			WaveTableFactory::Create( WaveTable::Type_Constant, 1) );

		AudioRecorder32 recorder( 2, 2 );
		recorder.Record( 0, 0, 0, element1 );
		recorder.Record( 0, 1, 0.25, element2 );
		recorder.Record( 1, 0, 0.50, element3 );
		recorder.Record( 1, 1, 0.75, element4 );

		std::vector< AudioData32 > audioData;
		recorder.GetAudioData( 0, audioData );
		
		AssertEqual( audioData.size(), 5 * Sampling_Rate_As_Double / 4 );
		int i = 0;
		for ( ; i < Sampling_Rate_As_Double / 4 + 1; i++ )
		{
			AssertEqual( audioData[ i ], 1 );
		}
		for ( ; i < 2 * Sampling_Rate_As_Double / 4; i++ )
		{
			AssertEqual( audioData[ i ], 2 );
		}

		audioData.clear();
		recorder.GetAudioData( 1, audioData );
		AssertEqual( audioData.size(), 7 * Sampling_Rate_As_Double / 4 );
		for ( i = 0; i < Sampling_Rate_As_Double / 2; i++ )
		{
			AssertEqual( audioData[ i ], 0 );
		}
		for ( ; i < 3 * Sampling_Rate_As_Double / 4; i++ )
		{
			AssertEqual( audioData[ i ], 1 );
		}
		for ( ; i < Sampling_Rate_As_Double + Sampling_Rate_As_Double / 2; i++ )
		{
			AssertEqual( audioData[ i ], 2 );
		}
		for ( ; i < Sampling_Rate_As_Double + 3 * Sampling_Rate_As_Double / 4; i++ )
		{
			AssertEqual( audioData[ i ], 1 );
		}
	}

	void AudioRecorderTester::Test_Record_029()
	{
		double time = 0;
		double length = 1.5;
		double powerOfX = 1;
		AudioRecorder32 recorder( 2, 1 );
		std::vector< AudioData32 > audioData;
		const WaveFunction& function = WaveFunctionFactory::CreateXSinX( powerOfX, 2 * length );
		const WaveTable& dynamicsTable = WaveTableFactory::Create( function, 1 );
		const WaveTable& soundTable = WaveTableFactory::Create( WaveTable::Type_Constant, 1, 1 );
		const SoundElement32* element = SoundElementFactory32::Create( soundTable, dynamicsTable, length );

		recorder.Record( 0, 0, 0, element );
		recorder.GetAudioData( 0, audioData );
		double delta = 1.0 / Sampling_Rate_As_Double;
		double count = audioData.size();
		for ( int i = 0; i < count; i++ ) {
			AssertEqual( audioData[ i ], static_cast< float >( function( time ) ) );
			if ( audioData[ i ] != static_cast< float >( function( time ) ) ) {
				cout << "i: " << i << ", time: " << time << endl; 
			}
			time += delta;
		}
	}
	
}